package com.info.zhiduoduo.repository.mapper.value;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.value.ValueServeDto;
import com.info.zhiduoduo.repository.entity.value.ValueServe;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 增值服务 mapper
 */

public interface ValueServeMapper extends BaseMapper<ValueServe> {


    @Select(" select vs.*,sd.dict_name as typeStr,sm1.managername as senderName,sm2.managername as sealedByName " +
            " FROM zdd_value_serve vs " +
            " LEFT JOIN zdd_system_dict sd ON vs.type = sd.id " +
            " LEFT JOIN zdd_system_manager sm1 on sm1.managerid = vs.sender " +
            " LEFT JOIN zdd_system_manager sm2 on sm2.managerid = vs.sealed_by " +
            " WHERE " +
            " IF( ISNULL(#{state})  , 1=1 ,  vs.state = #{state}   ) " +
            " AND IF( ISNULL(#{type}) or  #{type} = 0 , 1=1 , vs.customer_type = #{type}  ) " +
            " AND IF( ISNULL(#{customerId}) , 1=1 , vs.customer_id = #{customerId}   )  " +
            " order by vs.createtime desc   ")
    List<ValueServeDto> queryValueServeList(@Param("customerId") Integer customerId, @Param("state") Integer state , @Param("type")Integer type);


}
